﻿//++
//
// Copyright (c) Microsoft Corporation.  All rights reserved.
//
// Module Name:
//
//    ReadOnlyChannelControl.xaml.cs
//
// Abstract:
//    
//    Implements a read-only channel control.
//
//--

using System.Collections.Generic;
using System.Diagnostics;
using System.Windows;
using System.Windows.Input;

namespace Microsoft.EnhancedReminders.OutlookAddIn
{
    /// <summary>
    /// Implements a read-only channel control.
    /// </summary>
    public class ReadOnlyChannelControl : ChannelControl
    {
        /// <summary>
        /// Constructor.
        /// </summary>
        public ReadOnlyChannelControl()
            : base()
        {
            // Hide add/edit/delete buttons for read-only mode.
            addButton.Visibility = Visibility.Hidden;
            editButton.Visibility = Visibility.Hidden;
            deleteButton.Visibility = Visibility.Hidden;
        }

        /// <summary>
        /// Initializes the control with a set of channels.
        /// </summary>
        public override void Initialize(IEnumerable<NotificationChannel> channels)
        {
            base.Initialize(channels);
            
        }

        /// <summary>
        /// Test whether the "Edit" button should be enabled.
        /// </summary>
        protected override void EditCommandCanExecute(object sender, CanExecuteRoutedEventArgs e)
        {
            Debug.Assert(sender != null, "sender");
            Debug.Assert(e != null, "e");

            e.CanExecute = false; // Disallow channel editing in read-only mode.
        }
    }
}
